Release 10.1A: OpenEdge Development:
Progress 4GL Handbook


Writing your first procedure

Your first Progress procedure will be a real snowplow exercise, something very simple just to get you started with the language. But before you enter this first procedure, you need to make an adjustment to the code—your first change!

There are a fair number of fields in the Customer table, so the resulting formatting of all the fields in a limited display area would be a mess. In fact, one of the fields, the Comments field, is so large that the Progress run-time engine (also known as the interpreter) will balk at displaying it without some guidance from you on how to format and position it.

So it’s better to select just a few of the fields from the table to display to make it more manageable. Select the CustNum field, which is the unique customer number, the Name field, which is the customer name, and the City field, which is part of the customer’s address.

In the Progress 4GL, a list of fields is separated by spaces, so the new procedure becomes:

FOR EACH Customer: 
    DISPLAY CustNum Name City. 
END. 

To enter this procedure in the Procedure Editor:

  1. Return to the OpenEdge Desktop and click the icon with the pen and inkwell .
  2. In the Procedure Editor window that comes up, type your block of code:

You might notice the following about this code:

To execute your procedure, press the F2 key on your keyboard. This is the keyboard shortcut for the RUN command. Alternatively, you can select Compile Run from the Editor menu.

The Procedure Editor shows the first set of customer numbers, names, and cities:

To see the next pages of Customer numbers, names and cities, press the SPACE BAR a few times. Press ESCAPE to terminate the display. Otherwise, the display terminates after the last page of Customers has been displayed.

This little three-line procedure certainly does a lot for you, but it doesn’t produce an output display that you would put directly into an application. There are many qualifiers to the DISPLAY keyword in the statement that you can use to adjust its behavior and appearance, some of which you’ll see later on in this chapter. Fundamentally, the DISPLAY statement is not intended to produce polished output by itself for a graphical application. There are other statements in the language you can use to define the windows, browses, toolbar buttons, and other features of a complete user interface. You’ll get to know those statements in later chapters.

For the purposes of your introduction to the language, leave the display format as it is, so that you can see how the structure of the language itself is put together. That’s the snowplow part of this exercise. You’ll complete a little test procedure here that shows you a lot about the Progress 4GL, but which doesn’t represent the way you will write really finished applications (just as snowplowing shows you a lot about skiing but doesn’t represent how you will actually ski when you’re an expert). To do that, you work together with the development tools to let the tools do a lot of the work of putting together the user interface for you. After only a few chapters, you’ll be building complete application windows and all the logic that goes on behind them.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095